﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Forms;
using CollegeSim.CourseScheduler.Presentation.Facade;

namespace CollegeSim.CourseScheduler.Presentation
{
    // Author: Ryan Redburn
    // Project: Course Scheduler
    // Date: 5/19/2014

    public partial class FormCourseActionSelect : Form
    {
        #region [ Fields ]

        private readonly SchedulerFacade _facade;
        private int _courseID;
        private List<string> _courseInfo; 

        #endregion

        #region [ Constructors ]

        // Initialize form resources
        public FormCourseActionSelect(SchedulerFacade facade, int courseID)
        {
            InitializeComponent();
            _facade = facade;
            _courseID = courseID;
        }

        #endregion

        #region [ Events ]

        // Display given informatin on the form
        private void FormCourseActionSelect_Load(object sender, EventArgs e)
        {
            _courseInfo = _facade.GetCourseFromTempStore(_courseID);
            lblCourseID.Text += " " + _courseID.ToString(CultureInfo.InvariantCulture);
            lblSubNum.Text += " " + _courseInfo[1] + _courseInfo[2];
            lblTitle.Text += " " + _courseInfo[3];
        }

        // Starts update process
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            using (var frmCreate = new FormCourseCreate(_facade, true, _courseID))
            {
                frmCreate.ShowDialog();
            }
        }

        // Starts deletion process
        private void btnDelete_Click(object sender, EventArgs e)
        {
            using (var frmDelete = new FormCourseDelete(_facade, _courseID))
            {
                frmDelete.ShowDialog();
            }
        }

        // Closes the form
        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }

        #endregion
    }
}
